//Copyright 2010 Balazs Keri, Imre Keri
//
//This file is part of FireworksCreator.
//
//FireworksCreator is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//FireworksCreator is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with FireworksCreator.  If not, see <http://www.gnu.org/licenses/>.
//
#ifndef SIMPLETEXTVIEW_H
#define SIMPLETEXTVIEW_H
#include <QHash>
#include <QString>
#include <common/identified_fwd.h>
#include <model/particletemplate.h>
#include <model/emittertemplate.h>
#include <model/particleshooter_fwd.h>
#include "view.h"
#include "ui_stxtwidget.h"
//
class SimpleTextView : public QWidget, public View {
   Q_OBJECT
   Q_DISABLE_COPY(SimpleTextView)
public:
   SimpleTextView(QWidget *parent = 0);
   ~SimpleTextView();
protected:
   void handle_set_attr_group();
   void handle_attr_event(AttrEvent *event);
private:
   //data
   Ui::stxtwidget ui;
private:
   typedef QHash<QString, Identified*> NameMap;
   NameMap nameMap;
   QString currentKeyword;
   inline bool keywordIs(QString kw);
   bool parse1();
   bool parseTimeMarks(QTextStream &src, model::ParticleTemplate *pt);
   bool parseEmitterBlocks(QTextStream &src, model::ParticleTemplate *pt);
   bool parseColorControlPoints(QTextStream &src, model::ParticleTemplate *pt);
   bool parseFloatControlPoints(QTextStream &src, model::ParticleTemplate *pt, QList<model::ParticleTemplate::FloatControlPoint> &pointlist);
   bool parseParticleTemplate(QTextStream &src, model::ParticleTemplate *pt);
   bool parseEmitterBlock(QTextStream &src, model::EmitterTemplate::EmitterBlock &eblock);
   bool parseEmitterBlocks(QTextStream &src, model::EmitterTemplate *et);
   bool parseEmitterTemplate(QTextStream &src, model::EmitterTemplate *et);
   bool parseParticleShooter(QTextStream &src, model::ParticleShooter *ps);
   bool parse2();
private slots:
   void parseAndCreate();
};
#endif /* SIMPLETEXTVIEW_H */
